exports.tree=(arr)=>{
        let newArr = arr
      return arr.reduce((preVal,curVal)=>{
          newArr.forEach(item=>{
            if(curVal.pid==item.id){
                (item.children||(item.children=[])).push(curVal)
                if(item.pid==0&&preVal.indexOf(item)==-1){
                    preVal.push(item)
                }
            }   
          })
            return preVal
        },[])
}
